<!DOCTYPE html>
<html>

<head>
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta charset="utf-8" />
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="http://cdn.bootcss.com/socket.io/1.3.5/socket.io.js"></script>
</head>

<body>
    <div id="divlis"></div>
</body>
<script>
    $(document).ready(function () {
        window.username = 'others';
        var wsServer = 'ws://192.168.3.138:9504';
        var websocket = new WebSocket(wsServer);

        websocket.onopen = function (evt) {
            console.log('链接成功');
        };


        websocket.onmessage = function (evt) {
            console.log(evt.data);
            
            var data = JSON.parse(evt.data);
            var le = data.length;
            var html = '';
            for(var i = 0;i<le;i++)
            {
                console.log(data[i]);
                html += '<p><a href="/index2.html?id='+data[i].id+'">'+data[i].name+'</a></p>'
            }
            $("#divlis").append(html);

        };

        $("#basic-addon2").click(function () {
            var msg = $("#in").val();
            websocket.send(msg);
            $("#in").val('');
        });
    });

    // function openWindow(llsid)
    // {
    //         window.username = 'others';
    //         var wsServer = 'ws://192.168.3.138:9502';
    //         var websocket = new WebSocket(wsServer);

    //         websocket.onopen = function (evt) {
    //             console.log('链接成功');
    //             websocket.send(llsid);
    //         };

    //         websocket.onmessage = function (evt) {
    //             console.log(evt.data);
    //             var data = JSON.parse(evt.data);
    //             console.log(data);
    //         };
    // }
</script>

</html>